# plotly standard imports
import plotly.graph_objs as go
import chart_studio.plotly as py
# Cufflinks wrapper on plotly
import cufflinks
# Data science imports
import pandas as pd
import numpy as np
# Options for pandas
pd.options.display.max_columns = 30
# Display all cell outputs
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = 'all'
from plotly.offline import iplot, init_notebook_mode
cufflinks.go_offline(connected=True)
init_notebook_mode(connected=True)
# Set global theme
cufflinks.set_config_file(world_readable=True, theme='pearl')
Will try predict and denormalise model prediction
from src.load_datasets import load_datasets
from src.prepare_datasets import add_indicators
train, test = load_datasets()
test.index = pd.to_datetime(test.pop('timestamp'), unit='ms')
test
test[::60].iplot(subplots=True)
| open | high | low | close | volume | |
|---|---|---|---|---|---|
| timestamp | |||||
| 2020-04-22 12:42:00 | 6954.70000 | 6956.5 | 6954.600000 | 6956.5 | 0.336500 |
| 2020-04-22 12:43:00 | 6956.20000 | 6957.6 | 6952.800000 | 6955.5 | 0.038800 |
| 2020-04-22 12:44:00 | 6956.30000 | 6956.3 | 6955.779638 | 6956.0 | 0.300000 |
| 2020-04-22 12:45:00 | 6956.10000 | 6957.5 | 6955.300000 | 6955.3 | 0.113594 |
| 2020-04-22 12:46:00 | 6955.80000 | 6955.8 | 6955.300000 | 6955.3 | 0.016867 |
| ... | ... | ... | ... | ... | ... |
| 2021-03-09 18:50:00 | 53725.00000 | 53727.0 | 53725.000000 | 53727.0 | 1.119537 |
| 2021-03-09 18:51:00 | 53780.00000 | 53780.0 | 53779.000000 | 53779.0 | 0.010000 |
| 2021-03-09 18:52:00 | 53814.00000 | 53828.0 | 53814.000000 | 53828.0 | 0.016450 |
| 2021-03-09 18:53:00 | 53903.00000 | 53910.0 | 53902.000000 | 53910.0 | 0.012500 |
| 2021-03-09 18:54:00 | 53930.36601 | 53958.0 | 53930.366010 | 53953.0 | 1.040000 |
454074 rows × 5 columns
test = add_indicators(test)
test = test.dropna()
test.head()
test.iplot(subplots=True)
/usr/local/lib/python3.6/dist-packages/ta/trend.py:768: RuntimeWarning: invalid value encountered in double_scalars /usr/local/lib/python3.6/dist-packages/ta/trend.py:772: RuntimeWarning: invalid value encountered in double_scalars
| open | high | low | close | volume | volatility_bbm | volatility_bbh | volatility_bbl | trend_macd | momentum_rsi | volatility_kchi | trend_ichimoku_conv | trend_ichimoku_a | trend_ichimoku_b | momentum_stoch | momentum_stoch_signal | volatility_atr | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| timestamp | |||||||||||||||||
| 2020-04-22 12:42:00 | 6954.7 | 6956.5 | 6954.600000 | 6956.5 | 0.336500 | 6956.500 | 6956.500000 | 6956.500000 | 0.000000 | 100.000000 | 0.0 | 6955.55 | 6955.55 | 6955.55 | 100.000000 | 100.000000 | 0.0 |
| 2020-04-22 12:43:00 | 6956.2 | 6957.6 | 6952.800000 | 6955.5 | 0.038800 | 6956.000 | 6957.000000 | 6955.000000 | -0.079772 | 0.000000 | 0.0 | 6955.20 | 6955.20 | 6955.20 | 56.250000 | 78.125000 | 0.0 |
| 2020-04-22 12:44:00 | 6956.3 | 6956.3 | 6955.779638 | 6956.0 | 0.300000 | 6956.000 | 6956.816497 | 6955.183503 | -0.101476 | 35.000000 | 0.0 | 6955.20 | 6955.20 | 6955.20 | 66.666667 | 74.305556 | 0.0 |
| 2020-04-22 12:45:00 | 6956.1 | 6957.5 | 6955.300000 | 6955.3 | 0.113594 | 6955.825 | 6956.756397 | 6954.893603 | -0.173165 | 22.910373 | 0.0 | 6955.20 | 6955.20 | 6955.20 | 52.083333 | 58.333333 | 0.0 |
| 2020-04-22 12:46:00 | 6955.8 | 6955.8 | 6955.300000 | 6955.3 | 0.016867 | 6955.720 | 6956.652952 | 6954.787048 | -0.227358 | 22.910373 | 0.0 | 6955.20 | 6955.20 | 6955.20 | 52.083333 | 56.944444 | 0.0 |
from tqdm import tqdm
from src.prepare_datasets import get_prepared_datasets
train_norm, test_norm = get_prepared_datasets()
train_norm[::60].iplot(subplots=True)